;(function  ($) {
	var obj=function  () {
		var fileform;
		var btn;
		var loadEvent=function  () {
			btn.bind("change",uploadHandler);
		}
		var uploadHandler=function  () {
			var formData=new FormData();
			formData.append("file",btn[0].files[0]);
			$.ajax({
				type:"post",
				url:"upload.do",
				data:formData,
				dataType:'JSON',
				processData:false,
				contentType:false,
				success:function(res){
			$("img").attr("src","upload/"+res.imgname).css({"width":"180px"});
//				console.log(res);
				}
			});
		}
		return{
			init:function  () {
				fileform=$("form");
				btn=$("#file");
				
				loadEvent();
			}
		}
	}();
	obj.init();
})(jQuery);
